import { detailApi } from "@/utils/api";

// 详情模块
const detailModule = {
  namespaced: true,
  state: {
    // 详情数据
    detailInfo: {},
  },
  mutations: {
    // 详情数据的改变
    getDetailData(state, payload) {
      state.detailInfo = payload.result;
    },
    // 清除前一次的详情数据
    clearDetailData(state) {
      state.detailInfo = {};
    },
  },
  actions: {
    // 详情数据的请求
    async getDetailDataAsync({ commit }, payload) {
      const res = await detailApi(payload);
      commit("getDetailData", res);
    },
  },
};

export default detailModule;
